﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Winform_test_004
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            var stuSql = "select * from Students";

            var dt = DbHelper.GetDataTable(stuSql);

            dataGridView1.DataSource = dt;


        }

        private void button1_Click(object sender, EventArgs e)
        {
            var name = textBox1.Text;
            var stu = string.Format("select * from Students where StudentName like '%{0}%'", name);

            var dt = DbHelper.GetDataTable(stu);

            dataGridView1.DataSource = dt;

            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

            dataGridView1.ReadOnly = true;

            dataGridView1.AllowUserToAddRows = false;


        }
        //添加
        private void button2_Click(object sender, EventArgs e)
        {

        }
        //更新
        private void button3_Click(object sender, EventArgs e)

        {

        }
        //删除
        private void button4_Click(object sender, EventArgs e)
        {

        }
    }
}

